﻿using Ekton_Manage_DomainCore.Aggregate;
using Ekton_Manage_DTO.RequestModels.Product;
using Ekton_Manage_IBusiness;
using Ekton_Manage_InfrastructureCore.Common;
using Ekton_Manage_InfrastructureCore.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;


namespace Ekton_Manage_Web.Controllers
{
    /// <summary>
    /// 前端产品
    /// </summary>
    /// 
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize("Permission")]
    public class ApiProductsController : ControllerBase
    {
        private readonly IBaseRepository<product, int> _repository;
        private readonly IApiSelectProduct _apiSelectProduct;
        public ApiProductsController(IBaseRepository<product, int> repository, IApiSelectProduct apiSelectProduct)
        {
            _repository = repository;
            _apiSelectProduct = apiSelectProduct;
        }

        /// <summary>
        /// 选择产品/材料（第一次进入页面查询）
        /// </summary>
        [HttpGet]
        public async Task<Message> ApiGetProductList()
        {
            return await _apiSelectProduct.ApiGetProductList();
        }

        /// <summary>
        /// 选择产品/材料传入商品id
        /// </summary>
        [HttpGet]
        public async Task<Message> ApiGetIDProductList(int id)
        {
            return await _apiSelectProduct.ApiIdGetProductList(id);
        }


        /// <summary>
        /// 选择设计规格
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Message> ApiGetdesign(int id)
        {
            return await _apiSelectProduct.ApiIdGetdesign(id);
        }
    }
}
